let tab = document.getElementsByClassName('tab-bar')[0].children;
let tabContent = document.getElementsByClassName('img-content')[0].children[0].children;
let indexLink = document.getElementsByClassName('img-content')[0].children[0].children[0].children;
let indexTab = document.getElementsByClassName('img-content')[0].children[0].children;
let devBannerHeight = document.getElementsByClassName('dev-banner')[0];
let devBannerImgHeight = document.getElementsByClassName('dev-banner-img')[0].offsetHeight;
let btn = document.getElementsByClassName('back-top')[0];
let video = document.getElementsByTagName('video')[0];
let videoControl = document.getElementsByClassName('play-btn')[0];
getDevBannerHeight();
isShowBackTop();
/* 类数组转化为数组 */
let indexTabArray = Array.from(indexTab);
let devBannerImgHeightArray = Array.from(devBannerImgHeight);
indexTabArray.forEach((data) => {
  let indexLinkArray = Array.from(data.children);
  indexLinkArray.forEach(function (e){
    e.onmouseover = function() {
      e.className += ' active';
    }
    e.onmouseout = function() {
      if(e.className == 'long-img active') {
        e.className = 'long-img';
      }else {
        e.removeAttribute('class');
      }
    }
  })
})
window.onresize = function() {
  getDevBannerHeight();
}
videoControl.onclick = function() {
  playVideo();
}
video.onclick = function() {
  playVideo();
}
video.onplay = function() {
  video.controls = 'controls';
}
function getDevBannerHeight() {
  /* 解决absolute导致塌陷的问题 */
  devBannerHeight = document.getElementsByClassName('dev-banner')[0];
  devBannerImgHeight = document.getElementsByClassName('dev-banner-img')[0].offsetHeight;
  devBannerHeight.style.height = devBannerImgHeight + 'px';
}
function mouseOver(i){
  for(let j = 0; j<tab.length;j++){
    tabContent[j].className = '';
    tab[j].className = '';
  }
  tabContent[i].className = 'active';
  tab[i].className = 'active';
}
function backTop(){
  /* 返回顶部的动画 */
  let topTimer = setInterval(() => {
    console.log(1);
    if(scrollTop > 0){
      scrollTop -= 60;
      scrollTo(0, scrollTop);
    }else{
      clearInterval(topTimer);
    }
  }, 5)
}
function isShowBackTop() {
  scrollTop = document.documentElement.scrollTop || document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
  scrollTop > 0 ? btn.style.bottom = '40px' : btn.style.bottom = '-60px';
}
function playVideo() {
  if(video.paused) {
    videoControl.style.display = 'none';
    video.play();
  }
}